from flask import Flask, request

app = Flask(__name__)


@app.route("/test_form/lala/", methods=['POST'])
def test_form():
    print("in route")
    print(request.base_url)
    str_index = request.base_url.rfind(r"/", 0, -1)
    print("index:{}".format(str_index))
    print("sub str:{}".format(request.base_url[0: str_index]))
    auto_mode = request.form['auto_mode']
    auto_time = request.form['auto_time']
    return "mode is {mode}, time is {time}".format(mode=auto_mode, time=auto_time)


@app.route("/self_test", methods=['POST'])
def self_test():
    print("in self_test")
    value = request.form['key']
    print(value)
    return "get"


@app.route("/self_path", methods=["GET"])
def self_path():
    print(request.host_url)
    print(request.path)
    print(request.base_url)
    print(request.full_path)
    return request.full_path


if __name__ == "__main__":
    app.run()


